package modelo;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the modelo database table.
 * 
 */
@Entity
@Table(name="modelo")
@NamedQuery(name="Modelo.findAll", query="SELECT m FROM Modelo m")
public class Modelo implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(unique=true, nullable=false)
	private int idModelo;

	@Column(nullable=false, length=45)
	private String descricao;

	@Column(length=45)
	private String potencia;

	//bi-directional many-to-one association to Automovel
	@OneToMany(mappedBy="modelo")
	private List<Automovel> automovels;

	//bi-directional many-to-one association to Marca
	@ManyToOne
	@JoinColumn(name="marca_idmarca", nullable=false)
	private Marca marca;

	public Modelo() {
	}

	public int getIdModelo() {
		return this.idModelo;
	}

	public void setIdModelo(int idModelo) {
		this.idModelo = idModelo;
	}

	public String getDescricao() {
		return this.descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public String getPotencia() {
		return this.potencia;
	}

	public void setPotencia(String potencia) {
		this.potencia = potencia;
	}

	public List<Automovel> getAutomovels() {
		return this.automovels;
	}

	public void setAutomovels(List<Automovel> automovels) {
		this.automovels = automovels;
	}

	public Automovel addAutomovel(Automovel automovel) {
		getAutomovels().add(automovel);
		automovel.setModelo(this);

		return automovel;
	}

	public Automovel removeAutomovel(Automovel automovel) {
		getAutomovels().remove(automovel);
		automovel.setModelo(null);

		return automovel;
	}

	public Marca getMarca() {
		return this.marca;
	}

	public void setMarca(Marca marca) {
		this.marca = marca;
	}

}